<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>

<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content" style="padding:0px 15px;">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">           
                <div class="panel-body ">   
                   	<ul class="nav nav-tabs">
                        <foreach name="group_list" item="vo" key="k">
                     		<li <if condition="$k eq 'basic'">class="active"</if>><a href="javascript:void(0)" data-url="{:U('System/index',array('inc_type'=>$k))}" data-toggle="tab" onclick="goset(this)">{$vo}</a></li>
                     	</foreach>                        
                    </ul>
                    <!--表单数据-->
                    <form method="post" id="handlepost" action="{:U('System/handle')}">                    
                        <!--通用信息-->
                    <div class="tab-content" style="padding:20px 0px;">                 	  
                        <div class="tab-pane active" id="tab_tongyong">                           
                            <table class="table table-bordered">
                                <tbody>
<!--                                  
                              	<tr>
                                    <td>附件上传大小：</td>
                                    <td>                         		
                                        <select class="input-sm" name="file_size">
                                            <option value="1" <if condition="$config[file_size] eq 1">selected="selected"</if>>1M</option>
                                            <option value="2" <if condition="$config[file_size] eq 2">selected="selected"</if>>2M</option>
                                            <option value="3" <if condition="$config[file_size] eq 3">selected="selected"</if>>3M</option>
                                            <option value="5" <if condition="$config[file_size] eq 4">selected="selected"</if>>5M</option>
                                            <option value="10"<if condition="$config[file_size] eq 10">selected="selected"</if>>10M</option>
                                            <option value="50"<if condition="$config[file_size] eq 50">selected="selected"</if>>50M</option>
                                            <option value="100"<if condition="$config[file_size] eq 100">selected="selected"</if>>100M</option>
                                        </select>
                                    </td>
                                    <td></td>
                                </tr> -->
                                
                                <tr>
                                    <td>默认库存：</td>
                                    <td><input type="number"  pattern="^\d{1,}$" title="只能输入数字"  class="input-sm" name="default_storage" value="{$config.default_storage}" ></td>
                                	<td></td>
                                </tr>
                                
                                <tr>
                                    <td>库存预警数：</td>
                                    <td><input type="number"  pattern="^\d{1,}$" title="只能输入数字"  class="input-sm" name="warning_storage" value="{$config.warning_storage}" ></td>
                                	<td>当商品数量少于X件时，会在系统后台首页<库存预警>显示</td>
                                </tr>

                                <tr>
                                    <td>用户注册赠送{:C('POINT_NAME')}：</td>
                                    <td><input type="number"  pattern="^\d{1,}$" title="只能输入数字"  class="input-sm" name="reg_integral_self" value="{$config.reg_integral_self}" ></td>
                                        <td></td>
                                </tr>

                                <tr>
                                    <td>用户注册赠送上级{:C('POINT_NAME')}：</td>
                                    <td><input type="number"  pattern="^\d{1,}$" title="只能输入数字"  class="input-sm" name="reg_integral" value="{$config.reg_integral}" ></td>
                                        <td></td>
                                </tr>
                                <!-- <tr>
                                    <td>一级分销获取下级收益比例({:C('POINT_NAME')})</td>
                                    <td><input type="number" pattern="^\d{1,}$" class="input-sm" name="ad" value="{$config.ad}">%</td>
                                </tr> -->
                                <tr>
                                    <td>一级分销获取下级收益比例({:C('POINT_NAME')})</td>
                                    <td><input type="number" pattern="^\d{1,}$" class="input-sm" name="ad" value="{$config.ad}">%</td>
                                </tr>
                                <tr>
                                    <td>平台订单分成比例(%)</td>
                                    <td><input type="number" pattern="^\d{1,}$" class="input-sm" name="order_rate" value="{$config.order_rate}">%</td>
                                </tr>

                                <tr>
                                    <td>申请提现周期:</td>
                                    <td>
                                        <select name="with_shop_period" id="with_shop_period" onchange="change_period(this.value);">
                                            <option value="0">请选择</option>
                                            <option value="1" <if condition="$config[with_shop_period] eq '1'">selected="selected"</if>>周</option>
                                            <option value="2" <if condition="$config[with_shop_period] eq '2'">selected="selected"</if>>月</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>申请提现具体日期</td>
                                    <td>
                                        <div id="period_div"></div>
                                    </td>
                                </tr>

                                <tr>
                                    <td>最新app版本号</td>
                                    <td><input type="text"  name="app_version" value="{$config.app_version}"></td>
                                </tr>

                                <tr>
                                    <td>app更新地址</td>
                                    <td><input type="text"  name="app_url" value="{$config.app_url}"></td>
                                </tr>
                                <!-- <tr>
                                	<td>发票税率：</td>
                                	<td><input type="number" class="input-sm" name="tax">%</td>
                                	<td>当买家需要发票的时候就要增加<商品金额>*<税率>的费用</td>
                                </tr>   -->
                                <!--                                         
                            	<tr>
                                    <td>是否开启订单提醒：</td>
                                    <td >
                                       	 是<input type="radio" class="" name="is_remind" value="0" <if condition="$config[is_remind] eq 0"> checked="checked"</if>>
                                       	 否<input type="radio" class="" name="is_remind" value="1" <if condition="$config[is_remind] eq 1"> checked="checked"</if>>                               
                                    </td>
                                	<td></td>
                                </tr>
                                <tr>
                                	<td>发货后订单自动完成时间：</td>
                                	<td><input type="number" class="input-sm" name="order_finish_time">天</td>
                                	<td>发货后的X天，会自动变为完成状态</td>
                                </tr> 
                                <tr>
                                	<td>未付款订单自动取消时间：</td>
                                	<td><input type="number" class="input-sm" name="order_cancel_time">天</td>
                                	<td>未付款订单生成X天，会自动被取消掉</td>
                                </tr>
                                -->
                                <!-- <tr>
                                	<td>首页热门搜索词：</td>
                                	<td colspan="2"><input type="text" class="form-control" name="hot_keywords" value="{$config.hot_keywords}">
                                		<p class="text-warning">多个热门搜索关键词请用竖线|分开，如(手机|电脑)</p>
                                	</td>
                                </tr>  -->     
                            	<!-- <tr>
                                    <td>开启APP测试：</td>
                                    <td >
                                       	 关<input type="radio" class="" name="app_test" value="0" <if condition="$config[app_test] eq 0"> checked="checked"</if>>
                                       	 开<input type="radio" class="" name="app_test" value="1" <if condition="$config[app_test] eq 1"> checked="checked"</if>>                               
                                    </td>
                                	<td></td>
                                </tr>

                                <tr>
                                    <td>开启APP自动更新：</td>
                                    <td >
                                        关<input type="radio" class="" name="app_autoupdate" value="0" <if condition="$config[app_autoupdate] eq 0"> checked="checked"</if>>
                                        开<input type="radio" class="" name="app_autoupdate" value="1" <if condition="$config[app_autoupdate] eq 1"> checked="checked"</if>>
                                    </td>
                                    <td></td>
                                </tr>
 -->
                                </tbody> 
                                <tfoot>
                                	<tr>
                                	<td><input type="hidden" name="inc_type" value="{$inc_type}"></td>
                                	<td><input type="hidden" name="with_shop_period_data" id="with_shop_period_data"  value="{$config['with_shop_period_data']}"/></td>
                                	<td class="text-right"><input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存"></td>
                                	</tr>
                                </tfoot>                               
                                </table>
                        </div>                           
                    </div>              
			    	</form><!--表单数据-->
                </div>
            </div>
        </div>
    </section>
</div>

<script>

    $(document).ready(function(){
        get_province();
        change_period('{$config[with_shop_period]}');
    });

function adsubmit(){

    var arr_data = [];
    $.each($(".with_shop_period_data_class"), function(i, v){
        if($(v).attr('checked')){
            //alert($(v).val());
            arr_data.push($(v).val());
        }

    });
    if(arr_data.length > 0){
        var data_str = arr_data.join(',');
        $("#with_shop_period_data").val(data_str);
    }

	$('#handlepost').submit();

}

//<if condition="$config['with_shop_period'] eq '1' or $config['with_shop_period'] eq '2'">
    //alert({$config['with_shop_period_data']});
  //  change_period({$config['with_shop_period']});
//</if>



function goset(obj){
	window.location.href = $(obj).attr('data-url');
}

function change_period(period){
    var period_data = "{$config[with_shop_period_data]}";

    var value_str = '';
    if(period == 1){
        var arr_period_data = period_data.split(",");
        for(var i = 1; i <= 7; i++){
            value_str += "<input type='checkbox' value='"+i+"' class='with_shop_period_data_class' ";
            //console.log(jQuery.inArray(i, arr_period_data));
            if(jQuery.inArray(String(i), arr_period_data) != -1){
                value_str += " checked = 'true' ";
            }
            value_str += " onclick='change_checked(this);'/> "+ i + "&nbsp;&nbsp;&nbsp;&nbsp;";

        }
    }else if(period == 2){
        var arr_period_data = period_data.split(',');
        for(var i = 1; i <= 28; i++){
            value_str += "<input type='checkbox' value='"+i+"' class='with_shop_period_data_class' ";
            if(jQuery.inArray(String(i), arr_period_data) != -1){
                value_str += " checked = 'true' ";
            }
            value_str += "/> "+ i + "&nbsp;&nbsp;&nbsp;&nbsp;";
        }
    }

    $("#period_div").html('');
    $("#period_div").html(value_str);
}
function change_checked(obj){
    if($(obj).attr('checked')){
        $(obj).removeAttr('checked');
    }else{
        $(obj).attr('checked', true)
    }
    //alert($(obj).attr('checked'));
}
</script>
</body>
</html>